﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crm2011EventBinder.Serialization
{
    class Events
    {
        public String Name { get; set; }
        public Boolean Application { get; set; }
        public Boolean Active { get; set; }
        public String Attribute { get; set; }

        public override string ToString()
        {
            if(String.IsNullOrEmpty(Attribute))
                return String.Format("<events><event name=\"{0}\" application=\"{1}\" active=\"{2}\"><Handlers></Handlers></event></events>", Name, Application.ToString().ToLower(), Active.ToString().ToLower());
            else
                return String.Format("<events><event name=\"{0}\" application=\"{1}\" active=\"{2}\" attribute=\"{3}\"><Handlers></Handlers></event></events>", Name, Application.ToString().ToLower(), Active.ToString().ToLower(), Attribute);
        }

        public string InnerXml() {

            if (String.IsNullOrEmpty(Attribute))
                return String.Format("<event name=\"{0}\" application=\"{1}\" active=\"{2}\"><Handlers></Handlers></event>", Name, Application.ToString().ToLower(), Active.ToString().ToLower());
            else
                return String.Format("<event name=\"{0}\" application=\"{1}\" active=\"{2}\" attribute=\"{3}\"><Handlers></Handlers></event>", Name, Application.ToString().ToLower(), Active.ToString().ToLower(), Attribute);   

        }

    }
}
